// @ts-nocheck
import fetch from "@blueos.network.fetch"
import storage from '@blueos.storage.storage'

const getDeviceId = () => {
  const DEVICE_ID_KEY = "painter-deviceID";
  // return storage.getSync({ key: DEVICE_ID_KEY, global: true })
  return "123abc"
}


const host = 'http://121.37.46.189:8888'

/**
 * 获取壁纸
 * @returns 
 */
export const getWallpaper = () => {
  return new Promise((resolve, reject) => {
    const deviceID = getDeviceId()
    console.log("========")
    fetch.fetch({
      url: `${host}/v1/get_wallpaper?uid=${deviceID}`,
      method: 'get',
      responseType: 'json',
      header: { "Content-Type": "application/json" },
      timeout: 600,
      success: (res) => {
        if (res && res.data && res.data.data) {
          resolve(res.data.data)
        } else {
          reject()
        }
      },
      fail: (data, code) => {
        console.log('fail', data, code)
        reject()
      }
    })
  })
}